package com.jxin.mall.member.service.api;

import com.jxin.mall.entity.entity.GlobalRsp;
import com.jxin.mall.member.service.entity.dto.req.UserLoginReqDTO;
import com.jxin.mall.member.service.entity.dto.req.UserRegisterReqDTO;
import com.jxin.mall.member.service.entity.dto.rsp.UserLoginRspDTO;
import io.swagger.annotations.*;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * 会员登入注册接口
 * @author  蔡佳新
 * @version 1.0
 * @since   jdk 1.8
 */
@Api(tags = "会员登入注册接口")
@RequestMapping
public interface LoginRegisterService {

    /**
     * 会员注册
     * @param  userRegisterReqDTO 注册参数
     * @return 全局响应参数
     * @author 蔡佳新
     */
    @PostMapping(value = "/register", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "会员注册接口")
    @ApiResponses({@ApiResponse(code=200,message="响应请求成功"),
                   @ApiResponse(code=201,message="验证码不存在"),
                   @ApiResponse(code=202,message="验证码错误"),
                   @ApiResponse(code=205,message="关联QQ账号失败"),
                   @ApiResponse(code=206,message="关联微信账号失败"),
                   @ApiResponse(code=500,message="系统错误")})
    GlobalRsp register(@Valid UserRegisterReqDTO userRegisterReqDTO);
    /**
     * 会员登入
     * @param  userLoginReqDTO 登入参数
     * @return 全局响应参数
     * @author 蔡佳新
     */
    @PostMapping(value = "/login", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "会员登入接口", response = UserLoginRspDTO.class)
    @ApiResponses({@ApiResponse(code=200,message="响应请求成功"),
                   @ApiResponse(code=201,message="验证码不存在"),
                   @ApiResponse(code=202,message="验证码错误"),
                   @ApiResponse(code=203,message="账号密码错误"),
                   @ApiResponse(code=205,message="关联QQ账号失败"),
                   @ApiResponse(code=206,message="关联微信账号失败"),
                   @ApiResponse(code=207,message="QQ账号已关联"),
                   @ApiResponse(code=208,message="微信账号已关联"),
                   @ApiResponse(code=500,message="系统错误")})
    GlobalRsp login(@Valid UserLoginReqDTO userLoginReqDTO);

    /**
     * 会员退出
     * @param  token 令牌
     * @return 全局响应参数
     * @author 蔡佳新
     */
    @PostMapping(value = "/logout", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "会员登出接口", response = UserLoginRspDTO.class)
    @ApiResponses({@ApiResponse(code=200,message="响应请求成功"),
                   @ApiResponse(code=500,message="系统错误")})
    GlobalRsp logout(@ApiParam(value = "令牌", required = true) @RequestParam(name = "token") String token);

    /**
     * 获取登入图形验证码
     * @param  request  http请求
     * @param  response http响应
     * @author 蔡佳新
     */
    @GetMapping(value = "/getLoginVCImage", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "获取登入图形验证码", response = UserLoginRspDTO.class)
    void getLoginVCImage(@ApiParam(value = "http请求", required = true) HttpServletRequest request,
                         @ApiParam(value = "http响应", required = true) HttpServletResponse response);

    /**
     * 验证登入图形验证码
     * @param  request   http请求
     * @param  imageCode 验证码code
     * @return 全局响应对象
     * @author 蔡佳新
     */
    @PostMapping(value = "/validateLoginCode", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "验证登入图形验证码", response = UserLoginRspDTO.class)
    @ApiResponses({@ApiResponse(code=200,message="响应请求成功"),
                   @ApiResponse(code=500,message="系统错误")})
    GlobalRsp validateLoginCode(@ApiParam(value = "http请求", required = true) HttpServletRequest request,
                                @ApiParam(value = "令牌", required = true) @RequestParam(name = "imageCode") String imageCode);
    /**
     * PC端微信联合登入
     * @return 全局响应参数
     * @author 蔡佳新
     */
    @GetMapping(value = "/wxAllianceLoginInPC", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "微信联合登入", response = UserLoginRspDTO.class)
    GlobalRsp wxAllianceLoginInPC();

    /**
     * PC端获取微信授权地址
     * @return 全局响应参数
     * @author 蔡佳新
     */
    @GetMapping(value = "/getWxAccessUrlInPc", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "获取微信联合登入授权地址", response = UserLoginRspDTO.class)
    GlobalRsp getWxAccessUrlInPC();
}
